// https://org.modao.cc/app/277ce50586e8e01a98eeca6e44fab196#screen=sADF20F34611557385791584
//https://org.modao.cc/app/9fe2d9f671ae73d5894aca6dd2bc1b9b#screen=s151B772E0A1557636578154
import request from '@/router/axios';
import {
    parseTime,
    arr2params
} from '../util/util';
export const getUserData = (page) => request({
    url: '/admin/getUser',
    method: 'get',
    data: {
        page
    }
})

export const getRoleData = (data) => request({
    url: '/admin/role/list',
    method: 'post',
    data
});

export const updateRoleData = (data) => request({
    url: '/admin/role/update',
    method: 'post',
    data
});
export function removeRoleById(id) {
    return request({
        url: '/admin/role/remove-by-id',
        method: "post",
        data: {
            id
        }
    })
}
export function removeRoleByIds(ids) {
    return request({
        url: '/admin/role/remove-by-ids',
        method: "post",
        data: {
            ids
        }
    })
}

export const createRoleData = (data) => request({
    url: '/admin/role/create',
    method: "post",
    data
})


export const getDic = (type) => request({
    url: '/admin/getDic',
    method: 'get',
    data: {
        type
    }
})


export function listAllRoles(data) {
    return request({
        url: '/admin/list-all',
        method: 'post',
        data
    });
}

export const list = (data) => request({
    url: '/admin/manager/list',
    method: 'post',
    data
});
export const create = (data) => request({
    url: '/admin/manager/add',
    method: "post",
    data
});
export const update = (data) => request({
    url: '/admin/manager/modify',
    method: "post",
    data
});
export const remove = (id) => request({
    url: '/admin/manager/delete',
    method: "post",
    data: {
        id
    }
});

export const removeByIds = (ids) => {
    return request({
        url: '/admin/manager/delete-by-ids',
        method: "post",
        data: {
            ids
        }
    });
};

export function allCaptain() {
    return request.get('/admin/all-captain');
}

export function queryRoleCodeList(roleId) {
    return request.get('/admin/role/code-list?roleId=' + roleId);
}

export function saveRoleCodeList(roleId, codeList) {
    return request.post('/admin/role/save-code-list', {
        roleId,
        codeList
    });
}

export function queryCodeListOfCurrentUser() {
    return request.post('/admin/role/code-list-of-current-user');
}

export function resetPwd(id) {
    return request.post('/admin/manager/reset/pwd', { id })
}

export function setOffline(id) {
    return request.post('/admin/manager/active', { id, activeStatus: 0 })
}
export function setOnline(id) {
    return request.post('/admin/manager/active', { id, activeStatus: 1 })
}

export function updateAdminInfo(param) {
    return request.post('/admin/manager/modify_self', param);
}

export function updatePwd(param) {
    return request.post('/admin/manager/edit_pwd', param);
}
